package uk.ac.cam.tcs40.sidnet.menu;

import java.util.List;

import uk.ac.cam.tcs40.sidnet.R;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MealAdapter extends ArrayAdapter<Meal> {

	private final Context m_Context;
	private final List<Meal> m_Values;

	public MealAdapter(Context context, List<Meal> list) {
		super(context, R.layout.meal_list_item, list);
		m_Context = context;
		m_Values = list;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = (LayoutInflater) m_Context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View view = inflater.inflate(R.layout.meal_list_item, parent, false);
		
		Meal meal = m_Values.get(position);
		
		TextView tv = (TextView) view.findViewById(R.id.meal_list_item);
		tv.setText(meal.getMeal());
		
		if (meal.isVegetarian())
			tv.setTextColor(Color.rgb(0, 128, 0));
		else
			tv.setTextColor(Color.BLACK);
			
		return view;
	}

	@Override
	public boolean isEnabled(int position) {
		return false;
	}

}
